﻿using System.Collections.Generic;
using System.Linq;

namespace Pap.Data
{
    /// <summary>
    /// 
    /// </summary>
    public partial class CustomerLoan : ICustomerLoan
    {

        #region ICustomerLoan Members


        /// <summary>
        /// Gets the customer obj.
        /// </summary>
        public ICustomer CustomerObj
        {
            get { return this.Customer; }
        }

        /// <summary>
        /// Gets the guarantor obj.
        /// </summary>
        public ICustomer GuarantorObj
        {
            get { return this.Customer1; }
        }

        /// <summary>
        /// Gets the project stage.
        /// </summary>
        IProjectStage ICustomerLoan.ProjectStage
        {
            get { return this.ProjectStage; }
        }

        /// <summary>
        /// Gets the committee obj.
        /// </summary>
        public ICommittee CommitteeObj
        {
            get { return this.Committee; }
        }

        /// <summary>
        /// Gets the responsible user obj.
        /// </summary>
        public IUser ResponsibleUserObj
        {
            get
            {
                return this.User;
            }
        }

        /// <summary>
        /// Gets the loan type obj.
        /// </summary>
        ILookUpEntity ICustomerLoan.LoanTypeObj
        {
            get { return this.LoanType; }
        }

        /// <summary>
        /// Gets the loan payment method obj.
        /// </summary>
        public ILoanPaymentMethod LoanPaymentMethodObj
        {
            get { return this.LoanPaymentMethod; }
        }

        /// <summary>
        /// Gets the loan feasibility study.
        /// </summary>
        public IEnumerable<ILoanFeasibilityStudy> LoanFeasibilityStudy
        {
            get { return this.LoanFeasabilityStudies.OfType<ILoanFeasibilityStudy>(); }
        }

        /// <summary>
        /// Gets the feasibility study obj.
        /// </summary>
        public ILoanFeasibilityStudy FeasibilityStudyObj
        {
            get { return this.LoanFeasabilityStudies.FirstOrDefault(); }
        }

        /// <summary>
        /// Gets the social resarch obj.
        /// </summary>
        public ILoanSocialResearch SocialResarchObj
        {
            get { return this.LoanSocialResearches.FirstOrDefault(); }
        }

        /// <summary>
        /// Gets the board loan obj.
        /// </summary>
        public IBoardLoan BoardLoanObj
        {
            get
            {
                if (this.BoardLoans.Count() > 0)
                    return this.BoardLoans.First();
                else
                    return null;
            }
        }

        /// <summary>
        /// Gets or sets the receipt.
        /// </summary>
        /// <value>
        /// The receipt.
        /// </value>
        IReceipt ICustomerLoan.Receipt
        {
            get { return this.Receipt; }
            set { this.Receipt = value as Receipt; }
        }

        /// <summary>
        /// Gets the loan execution LST.
        /// </summary>
        IEnumerable<ILoanExecution> ICustomerLoan.LoanExecutionLst
        {
            get { return this.LoanExecutions.OfType<ILoanExecution>(); }
        }

        #endregion
    }
}
